<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>match_add</title>
		<link rel="shortcut icon" href="../images/my/favicon.ico" />
		<link rel="bookmark" href="../images/my/favicon.ico" />
		<link rel="stylesheet" href="../css/layui.css" />
		<link rel="stylesheet" href="../css/admin/common.css" />
		<link rel="stylesheet" href="../css/admin/update_my_base_info.css" />
	</head>

	<body style="background: #F6F6F6;">
		<div class="layui-fluid">
			<div class="layui-row">
				<div class="layui-col-md12">
					<div class="layui-card layui-anim layui-anim-upbit">
						<div class="layui-card-header">添加选手信息
							<span class="btn_right">
								<button type="button" id="back" title="返回" class="layui-btn layui-btn-normal layui-btn-xs" onclick="javascript:window.history.back(-1);"><i class="layui-icon">&#xe65c;</i>返回上一页</button>
								<button type="button" id="refresh" title="刷新" class="layui-btn layui-btn-normal layui-btn-xs"><i class="layui-icon layui-icon-refresh"></i></button>
							</span>
						</div>
						<div class="layui-card-body">
							<form class="layui-form" action="">
								<div class="layui-form-item layui-row">
									<label class="my_layui-form-label layui-col-md1 layui-col-sm1 layui-col-xs12">编号：</label>
									<div class="layui-col-md10 layui-col-sm10 layui-col-xs12">
										<input type="text" name="pno" required lay-verify="required|number" autocomplete="off" placeholder="编号" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item layui-row">
									<label class="my_layui-form-label layui-col-md1 layui-col-sm1 layui-col-xs12">选手姓名：</label>
									<div class="layui-col-md10 layui-col-sm10 layui-col-xs12">
										<input type="text" name="name" required lay-verify="required" placeholder="选手姓名" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item layui-row">
									<label class="my_layui-form-label layui-col-md1 layui-col-sm1 layui-col-xs12">头像：</label>
									<div class="layui-col-md10 layui-col-sm10 layui-col-xs12">
										<a href="" target="_blank"><img id="headimg" src="../images/my/photo.jpg" /></a>
										<input id="headimgurl" type="hidden" name="headimgurl" value="https://triedblog.oss-cn-beijing.aliyuncs.com/my/login.jpg" />
										<button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="uploadheadimg">
					  <i class="layui-icon">&#xe67c;</i>上传图片
					</button>
									</div>
								</div>
								<div class="layui-form-item layui-row">
									<label class="my_layui-form-label layui-col-md1 layui-col-sm1 layui-col-xs12">个人简介：</label>
									<div class="layui-col-md10 layui-col-sm10 layui-col-xs12">
										<textarea name="matchdesc" id="demo" style="display: none;"></textarea>
									</div>
								</div>
								<div class="layui-form-item layui-row">
									<label class="my_layui-form-label layui-col-md1 layui-col-sm1 layui-col-xs1 layui-hide-xs">&nbsp;</label>
									<button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo"></i><span>保存添加</span></button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="../layui.js"></script>
		<script type="text/javascript" src="../lay/system/admin/public.js"></script>
		<script>
			layui.use(['layer', 'form', 'upload','layedit'], function() {
				var layer = layui.layer,
					$ = layui.$,
					form = layui.form,
				upload = layui.upload,
				layedit = layui.layedit;
				var index=layedit.build('demo',{
					height:200
				}); //建立编辑器
				initData();
				//表单监听提交
				form.on('submit(formDemo)', function(data) {
					var matchdesc=layedit.getContent(index);
					var user_data = data.field;
					user_data.description=layedit.getContent(index)
					user_data=JSON.stringify(user_data)
					$.ajax({
						url: IP + '/api/admin/palyerUser',
						type: 'POST',
						data: user_data,
						success: function(result, status, xhr) {
							layer.closeAll('loading');
							layer.msg(result.msg, {
								icon: 1,
								time: 1000
							},function(){
								window.history.back(-1);
							});
						}
					});
					return false;
				});
				//上传头像实例
				var uploadInst = upload.render({
					elem: '#uploadheadimg',
					size: 5120,
					number: 1,
					url: '/upload/',
					before: function(obj) {
						layer.load();
					},
					done: function(res) {
						$('#headimgurl').val(res.data.src)
						$('#headimg').attr('src', res.data.src);
						layer.closeAll('loading');
					},
					error: function(index, upload) {
						layer.msg('上传异常', {
							icon: 2,
							time: 1000
						}, function() {
							layer.closeAll('loading');
							layer.msg('重新上传？', {
								time: 20000, //20s后自动关闭
								btn: ['是', '否'],
								btn1: function() {
									upload()
								}
							});
						});
					}
				});
				//初始化页面数据
				function initData(uid) {
					
				}
			});
		</script>
	</body>

</html>